home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DJGPP
/
CBGRX103.ZIP
/
contrib
/
libgrx
/
drivers
/
vesainfo.asm
< prev
next >
Wrap
Assembly Source File
|
1993-12-06
|
18KB
|
1,103 lines
ifndef ??version
?debug macro
endm
$comm macro name,dist,size,count
comm dist name:BYTE:count*size
endm
else
$comm macro name,dist,size,count
comm dist name[size]:BYTE:count
endm
endif
?debug S "vesainfo.c"
?debug C E99AA4BE1A0A76657361696E666F2E63
?debug C E920083A151B433A5C42494E5C5443435C494E434C5544455C7374+
?debug C 646C69622E68
?debug C E920083A151A433A5C42494E5C5443435C494E434C5544455C7374+
?debug C 64696F2E68
?debug C E920083A1518433A5C42494E5C5443435C494E434C5544455C646F+
?debug C 732E68
_TEXT segment byte public 'CODE'
_TEXT ends
DGROUP group _DATA,_BSS
assume cs:_TEXT,ds:DGROUP
_DATA segment word public 'DATA'
d@ label byte
d@w label word
_DATA ends
_BSS segment word public 'BSS'
b@ label byte
b@w label word
_BSS ends
_TEXT segment byte public 'CODE'
;
; int getinfo(VgaInfoBlock *vgainfo)
;
assume cs:_TEXT
_getinfo proc near
push bp
mov bp,sp
push si
push di
mov si,word ptr [bp+4]
;
; {
; _ES = FP_SEG(vgainfo);
;
mov ax,ds
mov es,ax
;
; _DI = FP_OFF(vgainfo);
;
mov di,si
;
; _AX = VESA_FUNC + VESA_VGA_INFO;
;
mov ax,20224
;
; geninterrupt(0x10);
;
int 16
;
; if(_AX != VESA_SUCCESS) return(0);
;
cmp ax,79
je short @1@74
xor ax,ax
jmp short @1@290
@1@74:
;
; if(vgainfo->VESASignature[0] != 'V') return(0);
;
cmp byte ptr [si],86
je short @1@122
xor ax,ax
jmp short @1@290
@1@122:
;
; if(vgainfo->VESASignature[1] != 'E') return(0);
;
cmp byte ptr [si+1],69
je short @1@170
xor ax,ax
jmp short @1@290
@1@170:
;
; if(vgainfo->VESASignature[2] != 'S') return(0);
;
cmp byte ptr [si+2],83
je short @1@218
xor ax,ax
jmp short @1@290
@1@218:
;
; if(vgainfo->VESASignature[3] != 'A') return(0);
;
cmp byte ptr [si+3],65
je short @1@266
xor ax,ax
jmp short @1@290
@1@266:
;
; return(1);
;
mov ax,1
jmp short @1@290
@1@290:
;
; }
;
pop di
pop si
pop bp
ret
_getinfo endp
;
; int getmodeinfo(int mode,ModeInfoBlock *modeinfo)
;
assume cs:_TEXT
_getmodeinfo proc near
push bp
mov bp,sp
push si
push di
mov si,word ptr [bp+6]
;
; {
; _ES = FP_SEG(modeinfo);
;
mov ax,ds
mov es,ax
;
; _DI = FP_OFF(modeinfo);
;
mov di,si
;
; _CX = mode;
;
mov cx,word ptr [bp+4]
;
; _AX = VESA_FUNC + VESA_MODE_INFO;
;
mov ax,20225
;
; geninterrupt(0x10);
;
int 16
;
; if(_AX != VESA_SUCCESS) return(0);
;
cmp ax,79
je short @2@74
xor ax,ax
jmp short @2@98
@2@74:
;
; return(modeinfo->ModeAttributes & MODE_SUPPORTED);
;
mov ax,word ptr [si]
and ax,1
jmp short @2@98
@2@98:
;
; }
;
pop di
pop si
pop bp
ret
_getmodeinfo endp
;
; void printinfo(VgaInfoBlock *vgainfo)
;
assume cs:_TEXT
_printinfo proc near
push bp
mov bp,sp
sub sp,8
push si
mov si,word ptr [bp+4]
;
; {
; char far *sp = vgainfo->OEMStringPtr;
;
mov ax,word ptr [si+8]
mov dx,word ptr [si+6]
mov word ptr [bp-4],dx
mov word ptr [bp-2],ax
;
; short far *mp = vgainfo->VideoModePtr;
;
mov ax,word ptr [si+16]
mov dx,word ptr [si+14]
mov word ptr [bp-8],dx
mov word ptr [bp-6],ax
;
;
; printf("VESASignature: \"%c%c%c%c\"\n",
;
;
; vgainfo->VESASignature[0],
; vgainfo->VESASignature[1],
; vgainfo->VESASignature[2],
; vgainfo->VESASignature[3]
; );
;
mov al,byte ptr [si+3]
cbw
push ax
mov al,byte ptr [si+2]
cbw
push ax
mov al,byte ptr [si+1]
cbw
push ax
mov al,byte ptr [si]
cbw
push ax
mov ax,offset DGROUP:s@
push ax
call near ptr _printf
add sp,10
;
; printf("VESAVersion:\t%d.%d\n",
;
;
; ((vgainfo->VESAVersion >> 8) & 0xff),
; (vgainfo->VESAVersion & 0xff)
; );
;
mov ax,word ptr [si+4]
and ax,255
push ax
mov ax,word ptr [si+4]
mov cl,8
sar ax,cl
and ax,255
push ax
mov ax,offset DGROUP:s@+27
push ax
call near ptr _printf
add sp,6
;
; printf("OEMStringPtr:\t\"");
;
mov ax,offset DGROUP:s@+47
push ax
call near ptr _printf
pop cx
jmp short @3@122
@3@50:
;
; while(*sp != '\0') putchar(*sp++);
;
mov ax,word ptr DGROUP:__streams+16
inc ax
mov word ptr DGROUP:__streams+16,ax
or ax,ax
jge short @3@98
les bx,dword ptr [bp-4]
inc word ptr [bp-4]
mov al,byte ptr es:[bx]
mov bx,word ptr DGROUP:__streams+26
inc word ptr DGROUP:__streams+26
mov byte ptr [bx],al
mov ah,0
jmp short @3@122
@3@98:
mov ax,offset DGROUP:__streams+16
push ax
les bx,dword ptr [bp-4]
inc word ptr [bp-4]
mov al,byte ptr es:[bx]
push ax
call near ptr __fputc
pop cx
pop cx
@3@122:
les bx,dword ptr [bp-4]
cmp byte ptr es:[bx],0
jne short @3@50
;
; printf("\"\nCapabilities:\t%ld\n",vgainfo->Capabilities);
;
push word ptr [si+12]
push word ptr [si+10]
mov ax,offset DGROUP:s@+63
push ax
call near ptr _printf
add sp,6
;
; printf("VideoModePtr:\t%Fp\n",mp);
;
push word ptr [bp-6]
push word ptr [bp-8]
mov ax,offset DGROUP:s@+84
push ax
call near ptr _printf
add sp,6
;
; printf("Video Modes:\t");
;
mov ax,offset DGROUP:s@+103
push ax
call near ptr _printf
pop cx
jmp short @3@194
@3@170:
;
; while(*mp != (-1)) printf("0x%x ",*mp++);
;
les bx,dword ptr [bp-8]
add word ptr [bp-8],2
push word ptr es:[bx]
mov ax,offset DGROUP:s@+117
push ax
call near ptr _printf
pop cx
pop cx
@3@194:
les bx,dword ptr [bp-8]
cmp word ptr es:[bx],65535
jne short @3@170
;
; printf("\n\n");
;
mov ax,offset DGROUP:s@+123
push ax
call near ptr _printf
pop cx
;
; }
;
pop si
mov sp,bp
pop bp
ret
_printinfo endp
_TEXT ends
_DATA segment word public 'DATA'
_modeattrbits label word
db 1
db 0
dw DGROUP:s@+126
db 2
db 0
dw DGROUP:s@+141
db 4
db 0
dw DGROUP:s@+154
db 8
db 0
dw DGROUP:s@+167
db 16
db 0
dw DGROUP:s@+180
db 0
db 0
db 2 dup (0)
_winattrbits label word
db 1
db 0
dw DGROUP:s@+196
db 2
db 0
dw DGROUP:s@+210
db 4
db 0
dw DGROUP:s@+223
db 0
db 0
db 2 dup (0)
_memorymodels label word
db 0
db 0
dw DGROUP:s@+236
db 1
db 0
dw DGROUP:s@+247
db 2
db 0
dw DGROUP:s@+257
db 3
db 0
dw DGROUP:s@+268
db 4
db 0
dw DGROUP:s@+281
db 5
db 0
dw DGROUP:s@+294
db 6
db 0
dw DGROUP:s@+307
db 0
db 0
db 2 dup (0)
_DATA ends
_TEXT segment byte public 'CODE'
;
; void printbits(int value,bitdef *def)
;
assume cs:_TEXT
_printbits proc near
push bp
mov bp,sp
push si
push di
mov si,word ptr [bp+6]
;
; {
; int prev = 0;
;
xor di,di
jmp short @4@170
@4@50:
;
;
; while(def->bit != 0) {
; if(value & def->bit) {
;
mov ax,word ptr [bp+4]
test word ptr [si],ax
je short @4@146
;
; if(prev) printf(" | ");
;
or di,di
je short @4@122
mov ax,offset DGROUP:s@+320
push ax
call near ptr _printf
pop cx
@4@122:
;
; printf(def->name);
;
push word ptr [si+2]
call near ptr _printf
pop cx
;
; prev = 1;
;
mov di,1
@4@146:
;
; }
; def++;
;
add si,4
@4@170:
cmp word ptr [si],0
jne short @4@50
;
; }
; if(!prev) printf("0");
;
or di,di
jne short @4@242
mov ax,offset DGROUP:s@+324
push ax
call near ptr _printf
pop cx
@4@242:
;
; printf("\n");
;
mov ax,offset DGROUP:s@+326
push ax
call near ptr _printf
pop cx
;
; }
;
pop di
pop si
pop bp
ret
_printbits endp
_TEXT ends
_BSS segment word public 'BSS'
db 50 dup (?)
_BSS ends
_TEXT segment byte public 'CODE'
;
; char *getmodelname(int model)
;
assume cs:_TEXT
_getmodelname proc near
push bp
mov bp,sp
push si
mov si,word ptr [bp+4]
;
; {
; static char temp[50];
;
; if(model < 0) return(sprintf(temp,"Invalid model [%d]",model),temp);
;
or si,si
jge short @5@74
push si
mov ax,offset DGROUP:s@+328
push ax
mov ax,offset DGROUP:b@+0
push ax
call near ptr _sprintf
add sp,6
mov ax,offset DGROUP:b@+0
jmp short @5@194
@5@74:
;
; if(model <= MODEL_256_NC) return(memorymodels[model].name);
;
cmp si,5
jg short @5@122
mov bx,si
shl bx,1
shl bx,1
mov ax,word ptr DGROUP:_memorymodels[bx+2]
jmp short @5@194
@5@122:
;
; if(model <= 15) return(sprintf(temp,"VESA model [%0x2x]",model),temp);
;
cmp si,15
jg short @5@170
push si
mov ax,offset DGROUP:s@+347
push ax
mov ax,offset DGROUP:b@+0
push ax
call near ptr _sprintf
add sp,6
mov ax,offset DGROUP:b@+0
jmp short @5@194
@5@170:
;
; return(sprintf(temp,"OEM model [%0x2x]",model),temp);
;
push si
mov ax,offset DGROUP:s@+366
push ax
mov ax,offset DGROUP:b@+0
push ax
call near ptr _sprintf
add sp,6
mov ax,offset DGROUP:b@+0
jmp short @5@194
@5@194:
;
; }
;
pop si
pop bp
ret
_getmodelname endp
;
; void printmodeinfo(int mode,ModeInfoBlock *modeinfo)
;
assume cs:_TEXT
_printmodeinfo proc near
push bp
mov bp,sp
push si
mov si,word ptr [bp+6]
;
; {
; printf("Mode 0x%x is supported\n",mode);
;
push word ptr [bp+4]
mov ax,offset DGROUP:s@+384
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" ModeAttributes:\t");
;
mov ax,offset DGROUP:s@+408
push ax
call near ptr _printf
pop cx
;
; printbits(modeinfo->ModeAttributes,modeattrbits);
;
mov ax,offset DGROUP:_modeattrbits
push ax
push word ptr [si]
call near ptr _printbits
pop cx
pop cx
;
; printf(" WinAAttributes:\t");
;
mov ax,offset DGROUP:s@+427
push ax
call near ptr _printf
pop cx
;
; printbits(modeinfo->WinAAttributes,winattrbits);
;
mov ax,offset DGROUP:_winattrbits
push ax
mov al,byte ptr [si+2]
cbw
push ax
call near ptr _printbits
pop cx
pop cx
;
; printf(" WinBAttributes:\t");
;
mov ax,offset DGROUP:s@+446
push ax
call near ptr _printf
pop cx
;
; printbits(modeinfo->WinBAttributes,winattrbits);
;
mov ax,offset DGROUP:_winattrbits
push ax
mov al,byte ptr [si+3]
cbw
push ax
call near ptr _printbits
pop cx
pop cx
;
; printf(" WinGranularity:\t%d\n",modeinfo->WinGranularity);
;
push word ptr [si+4]
mov ax,offset DGROUP:s@+465
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" WinSize:\t\t%d\n",modeinfo->WinSize);
;
push word ptr [si+6]
mov ax,offset DGROUP:s@+487
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" WinASegment:\t\t0x%04x\n",modeinfo->WinASegment);
;
push word ptr [si+8]
mov ax,offset DGROUP:s@+503
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" WinBSegment:\t\t0x%04x\n",modeinfo->WinBSegment);
;
push word ptr [si+10]
mov ax,offset DGROUP:s@+527
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" WinFuncPtr:\t\t\%Fp\n",modeinfo->WinFuncPtr);
;
push word ptr [si+14]
push word ptr [si+12]
mov ax,offset DGROUP:s@+551
push ax
call near ptr _printf
add sp,6
;
; printf(" BytesPerScanLine:\t%d\n",modeinfo->BytesPerScanLine);
;
push word ptr [si+16]
mov ax,offset DGROUP:s@+571
push ax
call near ptr _printf
pop cx
pop cx
;
; if(!(modeinfo->ModeAttributes & MODE_EXTINFO)) return;
;
test word ptr [si],2
jne short @6@74
jmp @6@98
@6@74:
;
; printf(" XResolution:\t\t%d\n",modeinfo->XResolution);
;
push word ptr [si+18]
mov ax,offset DGROUP:s@+595
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" YResolution:\t\t%d\n",modeinfo->YResolution);
;
push word ptr [si+20]
mov ax,offset DGROUP:s@+615
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" XCharSize:\t\t%d\n",modeinfo->XCharSize);
;
mov al,byte ptr [si+22]
cbw
push ax
mov ax,offset DGROUP:s@+635
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" YCharSize:\t\t%d\n",modeinfo->YCharSize);
;
mov al,byte ptr [si+23]
cbw
push ax
mov ax,offset DGROUP:s@+653
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" NumberOfPlanes:\t%d\n",modeinfo->NumberOfPlanes);
;
mov al,byte ptr [si+24]
cbw
push ax
mov ax,offset DGROUP:s@+671
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" BitsPerPixel:\t\t%d\n",modeinfo->BitsPerPixel);
;
mov al,byte ptr [si+25]
cbw
push ax
mov ax,offset DGROUP:s@+693
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" NumberOfBanks:\t%d\n",modeinfo->NumberOfBanks);
;
mov al,byte ptr [si+26]
cbw
push ax
mov ax,offset DGROUP:s@+714
push ax
call near ptr _printf
pop cx
pop cx
;
; printf(" MemoryModel:\t\t%d (%s)\n",modeinfo->MemoryModel,getmodelname(modeinfo->MemoryModel));
;
mov al,byte ptr [si+27]
cbw
push ax
call near ptr _getmodelname
pop cx
push ax
mov al,byte ptr [si+27]
cbw
push ax
mov ax,offset DGROUP:s@+735
push ax
call near ptr _printf
add sp,6
;
; printf(" BankSize:\t\t%d\n",modeinfo->BankSize);
;
mov al,byte ptr [si+28]
cbw
push ax
mov ax,offset DGROUP:s@+760
push ax
call near ptr _printf
pop cx
pop cx
@6@98:
;
; }
;
pop si
pop bp
ret
_printmodeinfo endp
;
; void main(void)
;
assume cs:_TEXT
_main proc near
push bp
mov bp,sp
sub sp,300
push si
;
; {
; VgaInfoBlock vgainfo;
; ModeInfoBlock modeinfo;
; short far *modeptr;
; int mode;
;
; if(getinfo(&vgainfo)) {
;
lea ax,word ptr [bp-260]
push ax
call near ptr _getinfo
pop cx
or ax,ax
je short @7@194
;
; printinfo(&vgainfo);
;
lea ax,word ptr [bp-260]
push ax
call near ptr _printinfo
pop cx
;
; modeptr = vgainfo.VideoModePtr;
;
mov ax,word ptr [bp-244]
mov dx,word ptr [bp-246]
mov word ptr [bp-4],dx
mov word ptr [bp-2],ax
jmp short @7@146
@7@74:
;
; while((mode = *modeptr++) != (-1)) {
; if(getmodeinfo(mode,&modeinfo)) printmodeinfo(mode,&modeinfo);
;
lea ax,word ptr [bp-300]
push ax
push si
call near ptr _getmodeinfo
pop cx
pop cx
or ax,ax
je short @7@122
lea ax,word ptr [bp-300]
push ax
push si
call near ptr _printmodeinfo
pop cx
pop cx
jmp short @7@146
@7@122:
;
; else printf("Mode 0x%x IS NOT SUPPORTED!\n",mode);
;
push si
mov ax,offset DGROUP:s@+777
push ax
call near ptr _printf
pop cx
pop cx
@7@146:
les bx,dword ptr [bp-4]
add word ptr [bp-4],2
mov ax,word ptr es:[bx]
mov si,ax
cmp ax,65535
jne short @7@74
;
; }
; }
;
jmp short @7@218
@7@194:
;
; else printf("VESA BIOS extensions not found\n");
;
mov ax,offset DGROUP:s@+806
push ax
call near ptr _printf
pop cx
@7@218:
;
; exit(0);
;
xor ax,ax
push ax
call near ptr _exit
pop cx
;
; }
;
pop si
mov sp,bp
pop bp
ret
_main endp
?debug C E9
_TEXT ends
_DATA segment word public 'DATA'
s@ label byte
db 'VESASignature: "%c%c%c%c"'
db 10
db 0
db 'VESAVersion:'
db 9
db '%d.%d'
db 10
db 0
db 'OEMStringPtr:'
db 9
db '"'
db 0
db '"'
db 10
db 'Capabilities:'
db 9
db '%ld'
db 10
db 0
db 'VideoModePtr:'
db 9
db '%Fp'
db 10
db 0
db 'Video Modes:'
db 9
db 0
db '0x%x '
db 0
db 10
db 10
db 0
db 'MODE_SUPPORTED'
db 0
db 'MODE_EXTINFO'
db 0
db 'MODE_SUPBIOS'
db 0
db 'MODE_ISCOLOR'
db 0
db 'MODE_ISGRAPHICS'
db 0
db 'WIN_SUPPORTED'
db 0
db 'WIN_READABLE'
db 0
db 'WIN_WRITABLE'
db 0
db 'MODEL_TEXT'
db 0
db 'MODEL_CGA'
db 0
db 'MODEL_HERC'
db 0
db 'MODEL_4PLANE'
db 0
db 'MODEL_PACKED'
db 0
db 'MODEL_256_NC'
db 0
db 'MODEL_DIRECT'
db 0
db ' | '
db 0
db '0'
db 0
db 10
db 0
db 'Invalid model [%d]'
db 0
db 'VESA model [%0x2x]'
db 0
db 'OEM model [%0x2x]'
db 0
db 'Mode 0x%x is supported'
db 10
db 0
db ' ModeAttributes:'
db 9
db 0
db ' WinAAttributes:'
db 9
db 0
db ' WinBAttributes:'
db 9
db 0
db ' WinGranularity:'
db 9
db '%d'
db 10
db 0
db ' WinSize:'
db 9
db 9
db '%d'
db 10
db 0
db ' WinASegment:'
db 9
db 9
db '0x%04x'
db 10
db 0
db ' WinBSegment:'
db 9
db 9
db '0x%04x'
db 10
db 0
db ' WinFuncPtr:'
db 9
db 9
db '%Fp'
db 10
db 0
db ' BytesPerScanLine:'
db 9
db '%d'
db 10
db 0
db ' XResolution:'
db 9
db 9
db '%d'
db 10
db 0
db ' YResolution:'
db 9
db 9
db '%d'
db 10
db 0
db ' XCharSize:'
db 9
db 9
db '%d'
db 10
db 0
db ' YCharSize:'
db 9
db 9
db '%d'
db 10
db 0
db ' NumberOfPlanes:'
db 9
db '%d'
db 10
db 0
db ' BitsPerPixel:'
db 9
db 9
db '%d'
db 10
db 0
db ' NumberOfBanks:'
db 9
db '%d'
db 10
db 0
db ' MemoryModel:'
db 9
db 9
db '%d (%s)'
db 10
db 0
db ' BankSize:'
db 9
db 9
db '%d'
db 10
db 0
db 'Mode 0x%x IS NOT SUPPORTED!'
db 10
db 0
db 'VESA BIOS extensions not found'
db 10
db 0
_DATA ends
_TEXT segment byte public 'CODE'
_TEXT ends
public _printinfo
public _winattrbits
public _getmodelname
public _memorymodels
extrn _printf:near
extrn __fputc:near
public _getmodeinfo
public _getinfo
public _modeattrbits
extrn _sprintf:near
public _main
public _printmodeinfo
extrn __streams:word
extrn _exit:near
public _printbits
end